import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/page/Home'
import Admin from '@/layout/Admin'
import Test from '@/page/Test/test'
import Login from '@/page/Login'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => console.log(err))
}

Router.prototype.goBack = function() {
    this.isBack = true　　;
    window.history.go(-1)
}

Vue.use(Router)

export default new Router({
    mode:'history',
    routes:[
        {
            path:'/',
            name:'Admin',
            component:Admin,
            redirect:'/home',
            children: [
                {
                    path:'home',
                    name:'Home',
                    component:Home
                },
                {
                    path:'test',
                    name:'Test',
                    component:Test
                }
            ]
        },
        {
            path: '/login',
            name:'Login',
            component:Login
        }
    ]
})